<!--
* description: 基础数据--交付专员排班表
* author:hum
* createdDate: 2021.5.31
-->
<template>
  <div class="app-container app-container-table">
    <one-table-template
      ref="multipleTable"
      :dynamic-buttons="tableButtons"
      :dynamic-components="tableComponents"
      :dynamic-api-config="apiConfig"
      :dynamic-table-cols="tableCols"
      :dynamic-form-fields="formField"
      :dynamic-is-show-select="false"
      :dynamic-is-show-more-btn="false"
    />

    <edit
      v-if="editPopupsVisible"
      :key="editPopupsKey"
      :popups-visible="editPopupsVisible"
      :data-for-form="editRowData"
      :popups-state="editPopupsState"
      @close="close"
    />
  </div>
</template>
<script>
import { oneTableWithViewTemplateMixins } from "@/components/mixins/oneTableWithViewTemplateMixins";
import OneTableTemplate from "@/components/templates/oneTable";
import edit from "./edit";
import { custApi } from "@/api/se/customerManagement.js";
import Vue from "vue";

export default {
  name: "scheduleOfDeliverySpecialist",
  components: {
    OneTableTemplate,
    edit,
  },
  mixins: [oneTableWithViewTemplateMixins],
  // 阻塞路由预加载网格中组件的数据
  beforeRouteEnter(to, from, next) {
    Vue.prototype.$ConfigCache.CacheConfig.initData(
      [to.path, "supplierMessage-edit"],
      () => {
        next();
      }
    );
  },

  data() {
    // 页面标识（与上面beforeRouteEnter中的对应）
    const viewPageCode = this.$route.path;
    // 绑定事件配置化事件
    this.$ConfigCache.CacheConfig.bindEvent(this, [viewPageCode]);
    return {
      titleName: "",
      editRowData: {},
      editPopupsState: "",
      editPopupsVisible: false,
      // 网格查询API配置对象
      apiConfig: custApi.deliverTypesettingFormToSpecialist,
      // 动态组件-按钮
      tableButtons: [
        {
          compKey: "btnKey5",
          size: "small",
          clickEvent: (index) => this.edit(),
          text: "排班表设置",
          position: "right",
        },
        {
          compKey: "btnKey1",
          type: "primary",
          size: "small",
          clickEvent: () => this.queryTable(1),
          text: this.$t("sys.button.query"),
          position: "right",
          fuzzySearch: true,
        },
        {
          compKey: "btnKey4",
          size: "small",
          clickEvent: () => this.reset(),
          text: this.$t("sys.button.reset"),
          position: "right", // 重置
        },
      ],
      // 动态组件-查询条件
      tableComponents:
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path] &&
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path]
          .tableComponents &&
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path]
          .tableComponents.length > 0
          ? this.$ConfigCache.CacheConfig.cacheData[this.$route.path]
              .tableComponents
          : [
              // 显示组件
              {
                compKey: "compKey1",
                labelName: "员工姓名：",
                codeField: "empName",
                isMul: false,
                component: () => import("@/components/org/commonInput"),
                type: "inputText",
                isMust: true,
              },
              {
                compKey: "compKey2",
                labelName: "日期：",
                codeField: "appointmentStartDate,appointmentEndDate",
                component: () =>
                  import("@/components/org/datePicker/datePicker"),
                dateType: "daterange",
                type: "inputText",
                isMul: false,
                isMust: true,
              },
              {
                compKey: "compKey3",
                labelName: "员工编码：",
                codeField: "empCode",
                isMul: false,
                component: () => import("@/components/org/commonInput"),
                type: "inputText",
                isMust: true,
              },
            ],
      // 动态生成网格列
      tableCols:
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path] &&
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path].tableCols &&
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path].tableCols
          .length > 0
          ? this.$ConfigCache.CacheConfig.cacheData[this.$route.path].tableCols
          : [
              {
                prop: "empCode",
                label: "员工编码",
              },
              {
                prop: "empName",
                label: "员工姓名",
              },
              {
                prop: "mobile",
                label: "员工电话",
              },
              {
                prop: "enableDate",
                label: "日期",
              },
              {
                prop: "timeQuantum13",
                label: "6:00~6:30",
              },
              {
                prop: "timeQuantum14",
                label: "6:30~7:00",
              },
              {
                prop: "timeQuantum15",
                label: "7:00~7:30",
              },
              {
                prop: "timeQuantum16",
                label: "7:30~8:00",
              },
              {
                prop: "timeQuantum17",
                label: "8:00~8:30",
              },
              {
                prop: "timeQuantum18",
                label: "8:30~9:00",
              },
              {
                prop: "timeQuantum19",
                label: "9:00~9:30",
              },
              {
                prop: "timeQuantum20",
                label: "9:30~10:00",
              },
              {
                prop: "timeQuantum21",
                label: "10:00~10:30",
              },
              {
                prop: "timeQuantum22",
                label: "10:30~11:00",
              },
              {
                prop: "timeQuantum23",
                label: "11:00~11:30",
              },
              {
                prop: "timeQuantum24",
                label: "11:30~12:00",
              },
              {
                prop: "timeQuantum25",
                label: "12:00~12:30",
              },
              {
                prop: "timeQuantum26",
                label: "12:30~13:00",
              },
              {
                prop: "timeQuantum27",
                label: "13:00~13:30",
              },
              {
                prop: "timeQuantum28",
                label: "13:30~14:00",
              },
              {
                prop: "timeQuantum29",
                label: "14:00~14:30",
              },
              {
                prop: "timeQuantum30",
                label: "14:30~15:00",
              },
              {
                prop: "timeQuantum31",
                label: "15:00~15:30",
              },
              {
                prop: "timeQuantum32",
                label: "15:30~16:00",
              },
              {
                prop: "timeQuantum33",
                label: "16:00~16:30",
              },
              {
                prop: "timeQuantum34",
                label: "16:30~17:00",
              },
              {
                prop: "timeQuantum35",
                label: "17:00~17:30",
              },
              {
                prop: "timeQuantum36",
                label: "17:30~18:00",
              },
              {
                prop: "timeQuantum37",
                label: "18:30~19:00",
              },
              {
                prop: "timeQuantum38",
                label: "18:30~19:00",
              },
              {
                prop: "timeQuantum39",
                label: "19:00~19:30",
              },
              {
                prop: "timeQuantum40",
                label: "19:30~20:00",
              },
            ],
      formField: {
        empName: "",
        appointmentStartDate: "",
        appointmentEndDate: "",
        empCode: "",
      },
      resetDialogKey: false,
    };
  },
  mounted() {
    this.queryTable(1);
  },
  methods: {
    edit() {
      this.editPopupsVisible = true;
    },
    close() {
      this.editPopupsVisible = false;
    },
  },
};
</script>
